Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow multiple compiler configs #170

Merged
merged 20 commits into from
Nov 15, 2024
Merged

feat: allow multiple compiler configs #170

merged 20 commits into from
Nov 15, 2024

Conversation

klkvr
Copy link
Member

@klkvr klkvr commented Jul 16, 2024

This adds CompilerSettings::Restrictions associated type which allows configuring constraints for compilation settings. Those constraints can be checked against a settings object and merged.

Ideally given a set of constraints we'd be able to automatically resolve configurations given only basic (default) config, though I think we can do this in follow-up. Current implementation requires user to provide us with concrete profiles such that for each defined constraint at least one of the profiles matches it. This should be enough for most of the usecases for now.

Profile to use is resolved in Graph similarly to version resolution.

The way this could look in foundry.toml is:

[profile.default]
# by default no via-ir and evm version is paris for everything
evm_version = "paris"
via_ir = false

# add cancun profile and via_ir profiles
additional_compiler_profiles = [{ evm_version = "cancun" }, {via_ir = true} ]

# enforce compiling some contracts with cancun, and some with via-ir
# if those contracts are imported by some items in the project, constraints will apply as well
compilation_constraints = [{path = "./**/*.cancun.sol", min_evm_version = "cancun" }, {path = "SomeComplexFile.sol", via_ir = true }] 

When writing artifacts, a profile name is added to artifact file name if the same contract was compiled with multiple artifacts.

@klkvr klkvr force-pushed the klkvr/settings-profiles branch 2 times, most recently from 0c2f7d8 to 26a2657 Compare November 6, 2024 02:20
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all of this makes sense,
was able to follow, but could use some additional docs

Comment on lines 8 to 10
pub trait CompilerSettingsRestrictions: Copy + Debug + Sync + Send + Clone + Default {
fn merge(self, other: Self) -> Option<Self>;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs docs

@klkvr klkvr marked this pull request as ready for review November 7, 2024 20:53
@klkvr klkvr requested a review from DaniPopes as a code owner November 7, 2024 20:53
@klkvr klkvr changed the title [wip] feat: allow multiple compiler configs feat: allow multiple compiler configs Nov 7, 2024
@klkvr klkvr requested a review from mattsse November 7, 2024 20:59
@klkvr klkvr self-assigned this Nov 11, 2024
@klkvr klkvr merged commit b5c2a49 into main Nov 15, 2024
2 of 15 checks passed
@DaniPopes DaniPopes deleted the klkvr/settings-profiles branch November 15, 2024 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Ready For Review
Development

Successfully merging this pull request may close these issues.

2 participants